package cn.leida.ruoyi.system.domain;

import cn.leida.ruoyi.common.annotation.Excel;
import cn.leida.ruoyi.common.annotation.Excel.ColumnType;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;
import cn.leida.ruoyi.common.core.domain.BaseEntity;

/**
 * 岗位表 sys_post
 *
 * @author liutietou
 * @since 1.0  2020-12-11
 */
@Data
@Entity
@Table(name = "sys_post")
public class SysPost extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 岗位序号
     */
    @Excel(name = "岗位序号", cellType = ColumnType.NUMERIC)
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "post_id")
    private Long postId;

    /**
     * 岗位编码
     */
    @Excel(name = "岗位编码")
    @NotBlank(message = "岗位编码不能为空")
    @Size(min = 0, max = 64, message = "岗位编码长度不能超过64个字符")
    @Column(name = "post_code")
    private String postCode;

    /**
     * 岗位名称
     */
    @Excel(name = "岗位名称")
    @NotBlank(message = "岗位名称不能为空")
    @Size(min = 0, max = 50, message = "岗位名称长度不能超过50个字符")
    @Column(name = "post_name",length = 50)
    private String postName;

    /**
     * 岗位排序
     */
    @Excel(name = "岗位排序")
    @Column(name = "post_sort")
    private Integer postSort;

    /**
     * 状态（0正常 1停用）
     */
    @Excel(name = "状态", readConverterExp = "0=正常,1=停用")
    @Column(name = "status",length = 10)
    private String status;

    /**
     * 创建者
     */
    @Column(name = "create_by",length = 64)
    private String createBy;

    /**
     * 创建时间
     */
    @Column(name = "create_time",length = 30)
    private String createTime;

    /**
     * 更新者
     */
    @Column(name = "update_by",length = 64)
    private String updateBy;

    /**
     * 更新时间
     */
    @Column(name = "update_time",length = 30)
    private String updateTime;

    /**
     * 备注
     */
    @Column(name = "remark",length = 500)
    private String remark;

    /**
     * 用户是否存在此岗位标识 默认不存在
     */
    @Transient
    private boolean flag = false;

    public void initUpdateTime(){
        updateTime = nowTime();
    }
    public void initCreateTime(){
        createTime = nowTime();
    }
}
